package com.sakura.hk.sakura.springboot.plugin;

import com.sakura.hk.sakura.springboot.plugin.task.*;
import org.gradle.api.*;


/**
 * @author HeKun
 */
public class SakuraBoot implements Plugin<Project> {

    public static final String MY_PLUGIN_NAME = "sakuraSptingBoot";

    @Override
    public void apply(Project project) {
        createExtension(project);
        registerPluginActions(project);

    }

    /**
     * 创建扩展,
     * 设置参数的地方
     *
     * @param project
     */
    private void createExtension(Project project) {
        project.getExtensions().create(MY_PLUGIN_NAME, SakuraExtension.class, project);
    }

    /**
     * 注册插件
     *
     * @param project
     */
    private void registerPluginActions(Project project) {
        SakuraInit.foundMyTask(project).setGroup(MY_PLUGIN_NAME);
        DecompressionSpringbootBuild.foundMyTask(project).setGroup(MY_PLUGIN_NAME);
        GenerateMyMainClassFile.foundMyTask(project).setGroup(MY_PLUGIN_NAME);
        SetSpringbootStartupMainClass.foundMyTask(project).setGroup(MY_PLUGIN_NAME);
        GenerateNewBuild.foundMyTask(project).setGroup(MY_PLUGIN_NAME);
        ClearCache.foundMyTask(project).setGroup(MY_PLUGIN_NAME);
        SakuraPlugInBuild.foundMyTask(project).setGroup(MY_PLUGIN_NAME);
    }
}
